package com.example.mapp;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.*;

import com.example.entity.maintenance.DebrisHalfMon;
import com.example.entity.maintenance.DebrisHalfYear;
import com.example.entity.maintenance.DebrisQuarter;
import com.example.entity.maintenance.DebrisYear;
import com.example.ext.entity.maintenance.ExtDebrisHalfMon;
import com.example.mapp.buildSql.MaintMappSql;

/**
 * Created by douyx on 2017/10/26.
 */
@Mapper
public interface   DebrisMapp {

	/**
	 * 新增杂物电梯半月保数据
	 * 
	 * @return
	 * @throws Exception
	 */
	@Insert(" insert into debris_half_mon (brake_clearance,brake_position,car_top,counter_weight,cproom_environment,door_auto_reset,door_guide,"
			+ "door_lock_contact,drive_host,electrical_contact,floor_display,landing_sill,limiter_part,locking_length,maintenance_end_date,"
			+ "maintenance_start_date,maintenance_user_sign_id1,maintenance_user_sign_id2,manual_emergency_operation,oil_cup,pit_environment,"
			+ "pit_stop,stop_device,type,well_light,elevator_num,maintenance_user_name,maintenance_user_name2," +
			" maintenance_user_id1,maintenance_user_id2," +
			" maintenance_party_id,is_in_time_maint,maintenancen_used_time,change_info,summary,xcfhcs,ldbh,other_photos) VALUES " +
			"(#{brakeClearance},#{brakePosition},"
			+ "#{carTop},#{counterWeight},#{cproomEnvironment},#{doorAutoReset},#{doorGuide},#{doorLockContact},#{driveHost},#{electricalContact},"
			+ "#{floorDisplay},#{landingSill},#{limiterPart},#{lockingLength},#{maintenanceEndDate},#{maintenanceStartDate},#{maintenanceUserSignId1},"
			+ "#{maintenanceUserSignId2},#{manualEmergencyOperation},#{oilCup},#{pitEnvironment},#{pitStop},"
			+ "#{stopDevice},#{type},#{wellLight},#{elevatorNum},#{maintenanceUserName},#{maintenanceUserName2}," +
			"#{maintenanceUserId1},#{maintenanceUserId2}," +
			"#{maintenancePartyId},#{isInTimeMaint},#{maintenancenUsedTime},#{changeInfo},#{summary},#{xcfhcs},#{ldbh},#{otherPhotos}) ")
	@SelectKey(statement = "select last_insert_id()", keyProperty = "id", keyColumn = "id", before = false, resultType = Long.class)
	public Long addDebrisHalfMon(DebrisHalfMon debrisHalfMon) throws Exception;


	/**
	 * 更新杂物电梯半月包数据
	 * @param map
	 * @return
	 * @throws Exception
	 */
	@Update("update debris_half_mon set safe_user_sign_id2=#{safeUserSignId2}," +
			"safe_user_name=#{safeUserName},safe_user_sign_time=#{safeUserSignTime}," +
			"status=#{status},used_party_opt=#{usedPartyOpt} where id=#{elevatoriMonId}")
	public void updateDebrisHalfMon(Map<String,Object> map) throws Exception;

	/**
     * 获取杂物电梯维保数据
     * @return
     * @throws Exception
     */
    @SelectProvider(
            type = MaintMappSql.class,
            method = "findDebrisList"
    )
    List<ExtDebrisHalfMon> findDebrisList(ExtDebrisHalfMon debrisHalfMon) throws Exception;
    
    @Select(" SELECT * from debris_half_mon where id = #{id}")
    DebrisHalfMon queryDebrisHalfMon(Long id) throws Exception;
	
	/**
	 * 新增杂物电梯季度保数据
	 * 
	 * @return
	 * @throws Exception
	 */
	@Insert(" insert into debris_quarter (brake_lining,door_guide_shoe,half_mon_id,limiter_wheel_groove,limiter_wheel_safety,lubricating_oil,"
			+ "shoe_linin,traction_wheel_groove,transmission_steel) VALUES (#{brakeLining},#{doorGuideShoe},#{halfMonId},#{limiterWheelGroove},"
			+ "#{limiterWheelSafety},#{lubricatingOil},#{shoeLinin},#{tractionWheelGroove},#{transmissionSteel}) ")
	@SelectKey(statement = "select last_insert_id()", keyProperty = "id", keyColumn = "id", before = false, resultType = Long.class)
	public Long addDebrisQuarter(DebrisQuarter debrisQuarter) throws Exception;
	
	@Select(" SELECT * from debris_quarter where half_mon_id = #{halfMonId}")
	DebrisQuarter queryDebrisQuarter(Long halfMonId) throws Exception;

	/**
	 * 新增杂物电梯半年保数据
	 * 
	 * @return
	 * @throws Exception
	 */
	@Insert(" insert into debris_half_year (all_instrument,buffer_distance,driving_wheel,limit_switch,limiter_wire_rope,line_terminals,motor_coupling,"
			+ "quarter_id,rope_combination,suspension_device,test_switch) VALUES (#{allInstrument},#{bufferDistance},#{drivingWheel},#{limitSwitch},"
			+ "#{limiterWireRope},#{lineTerminals},#{motorCoupling},#{quarterId},#{ropeCombination},#{suspensionDevice},#{testSwitch}) ")
	@SelectKey(statement = "select last_insert_id()", keyProperty = "id", keyColumn = "id", before = false, resultType = Long.class)
	public Long addDebrisHalfYear(DebrisHalfYear debrisHalfYear) throws Exception;
	
	@Select(" SELECT * from debris_half_year where quarter_id = #{quarterId}")
	DebrisHalfYear queryDebrisHalfYear(Long quarterId) throws Exception;

	/**
	 * 新增杂物电梯年保数据
	 * 
	 * @return
	 * @throws Exception
	 */
	@Insert(" insert into debris_year (bottom_mounting_bolt,brake_plunger,brake_spring_compression,buffer,contactor_contact,device_and_sill,"
			+ "guide,half_year_id,insulation_performance_test,limiter_safety_clamp_linkage_test,rail_bracket,safety_clamp_holder,top_mounting_bolt,"
			+ "traveling_cable,year_lubricating_oil) VALUES (#{bottomMountingBolt},#{brakePlunger},#{brakeSpringCompression},#{buffer},"
			+ "#{contactorContact},#{deviceAndSill},#{guide},#{halfYearId},#{insulationPerformanceTest},#{limiterSafetyClampLinkageTest},"
			+ "#{railBracket},#{safetyClampHolder},#{topMountingBolt},#{travelingCable},#{yearLubricatingOil}) ")
	public Long addDebrisYear(DebrisYear debrisYear) throws Exception;
	
	@Select(" SELECT * from debris_year where half_year_id = #{halfYearId}")
	DebrisYear queryDebrisYear(Long halfYearId) throws Exception;
}
